package com.czxy.demo01;

import java.io.*;
import java.util.HashSet;
import java.util.Set;

public class Test20 {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new FileReader("data.txt"));

        Set<String> set = new HashSet<>();
        String str = "";
        while ((str = br.readLine()) !=null ){
            for (int i = 0; i <str.length() ; i++) {
                String s = String.valueOf(str.charAt(i));
                set.add(s);
            }
        }

        BufferedWriter bw = new BufferedWriter(new FileWriter("result.txt"));

        for (String s : set) {
            bw.write(s);
            bw.flush();
        }

        br.close();
        bw.close();
        System.out.println("保存完毕");
    }
}
